//
//  BQGoodsAddressCell.m
//  我的收货地址
//
//  Created by mac on 16/11/19.
//  Copyright © 2016年 解延峰. All rights reserved.
//

#import "BQGoodsAddressCell.h"
#import "Masonry.h"
#import "UIColor+CZAddition.h"
@implementation BQGoodsAddressCell

- (void)awakeFromNib {
    [super awakeFromNib];

}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
            [self setupUI];
    }
    return self;
}
-(void)setModel:(BQGoodsAddressModel *)model{
    _model = model;
    
    self.nameLabel.text = model.accept_name;
    self.phoneLabel.text = model.telphone;
    self.addressLabel.text = model.address;
    self.cityLabel.text = model.city_name;
    self.districtLabel.text = model.district_name;
    self.genderBtn.titleLabel.text = model.gender;
}

-(void)setupUI{
    //创建控件
    UILabel * nameLabel = [[UILabel alloc]init];
    [nameLabel setFont:[UIFont systemFontOfSize:14]];
    nameLabel.textColor = [UIColor cz_colorWithHex:0x323232];
    [self.contentView addSubview:nameLabel];
    
    UILabel * phoneLabel = [[UILabel alloc]init];
    [phoneLabel setFont:[UIFont systemFontOfSize:14]];
    phoneLabel.textColor = [UIColor cz_colorWithHex:0x323232];
    [self.contentView addSubview:phoneLabel];
    
    UILabel * addressLabel = [[UILabel alloc]init];
    [addressLabel setFont:[UIFont systemFontOfSize:13]];
    addressLabel.textColor = [UIColor cz_colorWithHex:0xb4b4b4];
    [self.contentView addSubview:addressLabel];
    
    UILabel * bianj = [[UILabel alloc]init];
    bianj.text = @"编辑";
    bianj.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:bianj];
    
    UIView * line = [[UIView alloc]initWithFrame:CGRectMake(300, 15, 0.5, 40)];
    line.backgroundColor = [UIColor cz_colorWithHex:0xeeeeee];
    [self.contentView addSubview:line];
    
    //关联
    self.nameLabel = nameLabel;
    self.phoneLabel = phoneLabel;
    self.addressLabel = addressLabel;
    self.bianjLabel = bianj;
    self.line = line;
    
    //布局
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(15);
        make.left.offset(10);
        make.height.mas_equalTo(10);
        make.width.mas_equalTo(100);
    }];
    [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(15);
        make.left.equalTo(nameLabel.mas_right);
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(12);
    }];
    [addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLabel.mas_bottom).offset(20);
        make.left.equalTo(nameLabel);
        
    }];
    [bianj mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-25);
    }];

}

-(void)setFrame:(CGRect)frame
{
    frame.origin.x = 1;//这里间距为10，可以根据自己的情况调整
    frame.size.width -= 2 * frame.origin.x;
    frame.size.height -= 2 * frame.origin.x;
    [super setFrame:frame];
    
   // self.layer.masksToBounds = YES;
  //  self.layer.cornerRadius = 8.0;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
